// 影厅--表现层
var express = require('express');
var router = express.Router();
const {addData,getCinemas,getTheaters,remove,updateOne} = require("../service/theatersService")//自行引对应service方法


router.post('/addTheater',async function (req, res, next) {//添加影厅数据
    var {cinemasId,name,status}=req.body;
    if(status == "true"){//传来的状态是字符串，转为布尔值
        status = true
    } else if (status == "false"){
        status = false
    }
   let data= await addData({cinemasId,name,status});
   res.send(data);
  });
router.get('/getCinemas',async function(req,res,next){//请求影院数据
    const data=await getCinemas();
    res.send(data);
});
router.get('/getTheaters',async function (req, res, next) {//请求影厅数据
   const data=await getTheaters()
   res.send(data);
  });
router.delete('/:_id', async function (req, res, next) {//删除影厅数据
    let data=req.params;
    res.send(await remove(data)) 
  });
  router.patch('/:_id', async function (req, res, next) { //更改影厅数据
    const _id=req.params;
    const {title,name,status}=req.body;
    const data =await updateOne(_id,{title,name,status});
    res.send(data) ;
  });
module.exports = router;